/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.uff.pgci.sgca.gateway.command;

import br.uff.pgci.sgca.gateway.model.Mensagem;
import java.net.InetSocketAddress;
import java.nio.channels.DatagramChannel;
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;

/**
 *
 * @author anapaula
 */
public class ComandoColetaDeApontamentos extends SimpleChannelUpstreamHandler {

    public static Integer ID_1_COLETA_DE_APONTAMENTOS = 1;

    private static long qt_chamada = 0L;

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
        System.out.println("Vai ao banco..");

        Mensagem msg = (Mensagem) e.getMessage();

        System.out.println("Inicia coleta do equipamento:" + msg.getIdEquipamento());

        ctx.getChannel().write("OK!", e.getRemoteAddress());

        qt_chamada++;

        System.out.println("qt_chamada="+qt_chamada);
    }

}
